package com.zzyl.controller.web;

import com.zzyl.base.ResponseResult;
import com.zzyl.controller.BaseController;
import com.zzyl.entity.Bed;
import com.zzyl.service.BedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class BedController extends BaseController {
    @Autowired
    private BedService bedService;

    //新增床位
    @PostMapping("/bed/create")
    public ResponseResult creat(@RequestBody Bed bed){
        bed.setBedStatus(0);
        bedService.save(bed);
        return success();
    }

    //根据id查询床位
    @GetMapping("/bed/read/{id}")
    public ResponseResult read(@PathVariable("id") Long id){
        return success(bedService.getById(id));
    }

    //修改床位
    @PutMapping("/bed/update")
    public ResponseResult update(@RequestBody Bed bed){
        bedService.updateById(bed);
        return success();
    }

    //删除床位
    @DeleteMapping("/bed/delete/{id}")
    public ResponseResult delete(@PathVariable Long id){
        bedService.removeById(id);
        return success();
    }
}
